package io.github.loserya.core.sdk.aggregate.base;

import io.github.loserya.utils.func.SFunction;
import org.springframework.data.mongodb.core.aggregation.AggregationOptions;

import java.io.Serializable;


@SuppressWarnings("all")
public interface MogoFuncAggregate<lambda, Q, R> extends Serializable {

    default lambda groupBy(SFunction<Q, ?>... column) {
        return groupBy(true, column);
    }

    default lambda orderByDesc(SFunction<R, ?>... column) {
        return orderByDesc(true, column);
    }

    default lambda orderByAsc(SFunction<R, ?>... column) {
        return orderByAsc(true, column);
    }

    default lambda skip(int skip) {
        return skip(true, skip);
    }

    default lambda skip(long skip) {
        return skip(true, skip);
    }

    default lambda limit(int limit) {
        return limit(true, limit);
    }

    default lambda limit(Long limit) {
        return limit(true, limit);
    }

    lambda groupBy(boolean condition, SFunction<Q, ?>... column);

    lambda orderByDesc(boolean condition, SFunction<R, ?>... column);

    lambda orderByAsc(boolean condition, SFunction<R, ?>... column);

    default lambda skip(boolean condition, int skip) {
        return skip(condition, (long) skip);
    }

    lambda skip(boolean condition, long skip);

    default lambda limit(boolean condition, int limit) {
        return limit(condition, (long) limit);
    }

    lambda limit(boolean condition, Long limit);

    lambda options(AggregationOptions options);

    lambda options(boolean condition, AggregationOptions options);

}
